# try:
#     num = 1.txt/0   # 除零异常
#
# except Exception as result:
#     print("出现异常了: %s" % result)

while True:
    try:
        num = int(input("请输入数字:"))  # 若出现异常，则赋值也不会执行，直接跳转到except
        print(10/num)
        break
    except ValueError:
        print("请输入正确的数字")
    except ZeroDivisionError:
        print("除数不能为0")
    except  Exception as result:
        print("未知异常：%s" % result)
        print(result.__traceback__.tb_frame.f_globals["__file__"])  #  获取异常所在的文件名
        print(result.__traceback__.tb_lineno)   # 获取异常所在行号
    else:
        pass
    finally:
        print("无论是否出现异常，都会执行")

print("程序执行至此")